Code used in the "Common Control"
Below are commonly used code snippets for use in the Common Control section of MOM.
Conditional Assignment
$x = 4 if ($a == 2);
Declare answer types for multipart
$anstypes = array("number", "choices");
Assign weights to multipart parts
$answeights = array(0.5, 0.5);
Declare answer value(s)
$answer[0] = "5";
Declare choices for a question
$choices[1] = array("Yes", "No");
Control formatting of answer display
$displayformat = "decimal";
Require decimal precision
$reqdecimals = 2;
Set absolute tolerance
$abstolerance = 0.01;
Set relative tolerance
$reltolerance = 0.001;
Load custom macro library
loadlibrary("stats");
Generate random int from range
$x = rand(1, 10);
Generate random float from range
$r = rand(100, 200)/100;
Choose random decimal from array
$alpha = $alphas[rand(0,2)]; // $alphas = array(0.01, 0.05,
0.10);
Create array of random values
$a,$b = diffrands(1,10,2);
Round variable $r to decimal places
$z = round($r, 2);
Code used in the "Question Text"
Curabitur sit amet mauris morbi in dui quis est pulvinar ullamcorper. Nulla facilisi.
Answer Box Placement
<p>What is 2 + 2? $answerbox</p>
Math Expression
`x^2 + 4x + 4`
Hint Location
<!-- <p>$hintloc</p> -->
Apply Custom CSS Styling from Another Problem
// Common Control
includecodefrom(1610504);
// Top of Question Text
$css
Code used anywhere in MOM
The following symbols are available to use in most parts of MyOpenMath by wrapping them in backtick () marks. For more examples and full syntax details, please visit ASCIIMath's website. ASCIIMathML was developed by Peter Jipsen, Chapman University.
Basic Operations
Type | See |
---|---|
+ | `+` |
- | `-` |
* | `*` |
/ | `/` |
2^3 | `2^3` |
sqrt(x) | `sqrt(x)` |
root(3)(x) | `root(3)(x)` |
Relations
Type | See |
---|---|
= | `=` |
!= | `!=` |
< | `<`< /td> |
<= | `<=`< /td> |
> | `>` |
>= | `>=` |
in | `in` |
notin | `notin` |
subset | `subset` |
supe | `supe` |
Calculus
Type | See |
---|---|
int | `int` |
int_a^b | `int_a^b` |
sum | `sum` |
sum_(i=1)^n | `sum_(i=1)^n` |
lim_(x->0) | `lim_(x->0)` |
del | `del` |
grad | `grad` |
Symbols
Type | See |
---|---|
oo | `oo` |
pi | `pi` |
theta | `theta` |
phi | `phi` |
sigma | `sigma` |
Delta | `Delta` |
Gamma | `Gamma` |
lambda | `lambda` |
Greek Letters
Type | See |
---|---|
alpha | `alpha` |
beta | `beta` |
gamma | `gamma` |
delta | `delta` |
epsilon | `epsilon` |
zeta | `zeta` |
eta | `eta` |
theta | `theta` |
iota | `iota` |
kappa | `kappa` |
lambda | `lambda` |
mu | `mu` |
nu | `nu` |
xi | `xi` |
Xi | `Xi` |
pi | `pi` |
rho | `rho` |
sigma | `sigma` |
tau | `tau` |
upsilon | `upsilon` |
phi | `phi` |
chi | `chi` |
psi | `psi` |
omega | `omega` |